# -*- coding: utf-8 -*-

from math import *

def blh2ecef(lat,lon,hei):
    Lambda=lon*pi/180
    Theta=lat*pi/180
    h=hei
    RE_WGS84=6378137.0           #earth semimajor axis (WGS84) (m) =a 长半径
    FE_WGS84=(1.0/298.257223563) #earth flattening (WGS84) =(a-b)/a
    e2=FE_WGS84*(2.0-FE_WGS84)
    N=RE_WGS84/sqrt(1.0-e2*sin(Theta)**2)
    
    return ((N+h)*cos(Theta)*cos(Lambda), (N+h)*cos(Theta)*sin(Lambda), (N*(1-e2)+h)*sin(Theta))